using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class UI_ScrollingRawImage : MonoBehaviour
{
	[SerializeField]
	private RawImage _img;

	[SerializeField]
	private float _x;

	[SerializeField]
	private float _y;

	[SerializeField]
	private bool AffectedBySimplifyVFX;

	[Header("Random Controls")]
	[SerializeField]
	private bool SlowlyRandom;

	[SerializeField]
	private float _xMin;

	[SerializeField]
	private float _yMin;

	[SerializeField]
	private float _xMax;

	[SerializeField]
	private float _yMax;

	[SerializeField]
	private float RandomSpeed;

	private bool simplifyvfx;

	private void Awake()
	{
		if (SlowlyRandom)
		{
			((MonoBehaviour)this).StartCoroutine(RandomChange());
		}
		if (AffectedBySimplifyVFX)
		{
			((MonoBehaviour)this).StartCoroutine(SettingsCheckTick());
		}
	}

	private void Update()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		if (!simplifyvfx)
		{
			RawImage img = _img;
			Rect uvRect = _img.uvRect;
			Vector2 val = ((Rect)(ref uvRect)).position + new Vector2(_x, _y) * Time.unscaledDeltaTime;
			uvRect = _img.uvRect;
			img.uvRect = new Rect(val, ((Rect)(ref uvRect)).size);
		}
	}

	private IEnumerator RandomChange()
	{
		if (!simplifyvfx)
		{
			_x = Mathf.Lerp(_x, Random.Range(_xMin, _xMax), RandomSpeed * Time.unscaledDeltaTime);
			_y = Mathf.Lerp(_y, Random.Range(_yMin, _yMax), RandomSpeed * Time.unscaledDeltaTime);
		}
		yield return (object)new WaitForSecondsRealtime(0.25f);
		((MonoBehaviour)this).StartCoroutine(RandomChange());
	}

	private IEnumerator SettingsCheckTick()
	{
		yield return (object)new WaitForSecondsRealtime(0.25f);
		simplifyvfx = SettingsManager.Instance.GetBoolSettingValue("SimpleVFX");
		((MonoBehaviour)this).StartCoroutine(SettingsCheckTick());
	}
}
